package com.cn.kabalifeuser.ui.my.activity;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.cn.kabalifeuser.R;
import com.cn.kabalifeuser.base.IBaseActivity;
import com.cn.kabalifeuser.config.CustomRefreshListener;
import com.cn.kabalifeuser.config.LoginHelper;
import com.cn.kabalifeuser.config.RefreshHelper;
import com.cn.kabalifeuser.ui.my.bean.ReportFormListBean;
import com.cn.kabalifeuser.utils.RxToast;
import com.flyco.roundview.RoundTextView;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by 晓林 on 2020/9/4.
 * function: 我的报表
 */
public class ReportFormAcivity extends IBaseActivity<ReportFormView, ReportFormPresenter> implements ReportFormView {
    @BindView(R.id.ll_btn_left)
    LinearLayout llBtnLeft;
    @BindView(R.id.tv_money)
    TextView tvMoney;
    @BindView(R.id.tv_total)
    TextView tvTotal;
    @BindView(R.id.tv_cash)
    TextView tvCash;
    @BindView(R.id.tv_account)
    TextView tvAccount;
    @BindView(R.id.tv_btn_tx)
    RoundTextView tvBtnTx;
    @BindView(R.id.tv_day_account)
    TextView tvDayAccount;
    @BindView(R.id.tv_day_fans)
    TextView tvDayFans;
    @BindView(R.id.tv_day_cash)
    TextView tvDayCash;
    @BindView(R.id.tv_day_number)
    TextView tvDayNumber;
    @BindView(R.id.tv_day_true_cash)
    TextView tvDayTrueCash;
    @BindView(R.id.tv_week_account)
    TextView tvWeekAccount;
    @BindView(R.id.tv_week_fans)
    TextView tvWeekFans;
    @BindView(R.id.tv_week_cash)
    TextView tvWeekCash;
    @BindView(R.id.tv_week_number)
    TextView tvWeekNumber;
    @BindView(R.id.tv_week_true_cash)
    TextView tvWeekTrueCash;
    @BindView(R.id.tv_month_account)
    TextView tvMonthAccount;
    @BindView(R.id.tv_month_fans)
    TextView tvMonthFans;
    @BindView(R.id.tv_month_cash)
    TextView tvMonthCash;
    @BindView(R.id.tv_month_number)
    TextView tvMonthNumber;
    @BindView(R.id.tv_month_true_cash)
    TextView tvMonthTrueCash;
    @BindView(R.id.tv_year_account)
    TextView tvYearAccount;
    @BindView(R.id.tv_year_fans)
    TextView tvYearFans;
    @BindView(R.id.tv_year_cash)
    TextView tvYearCash;
    @BindView(R.id.tv_year_number)
    TextView tvYearNumber;
    @BindView(R.id.tv_year_true_cash)
    TextView tvYearTrueCash;
    @BindView(R.id.refreshLayout)
    SmartRefreshLayout refreshLayout;

    String money;

    @Override
    protected ReportFormPresenter createPresenter() {
        return new ReportFormPresenter();
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_report_form;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        super.initView(savedInstanceState);


    }

    @Override
    protected void onResume() {
        super.onResume();
        mPresenter.onReportFormData(LoginHelper.getLonginData().getResult());
    }

    @Override
    public void initRefreshLayout() {
        RefreshHelper.initRefreshLayout(refreshLayout, new CustomRefreshListener() {
            @Override
            public void _onRefresh(RefreshLayout refreshLayout) {
                pagehttp = 1;
                mPresenter.onReportFormData(LoginHelper.getLonginData().getResult());
            }

            @Override
            public void _onLoadMore(RefreshLayout refreshLayout) {
//                pagehttp++;
//                if (null != mList) {
//                    getListData();
//                }
            }
        });
    }

    @Override
    public void onReLoggedIn(String msg) {
        RxToast.error(msg);
        LoginHelper.againGoToLoginActivity(getMe());
    }

    @Override
    public void onError(String msg) {
        RxToast.error(msg);
    }

    @Override
    public Context _getContext() {
        return null;
    }

    @Override
    public void onReportFormSuccess(ReportFormListBean bean) {
        RefreshHelper.finishRefresh(refreshLayout, pagehttp);
        money = bean.getResult().getMoney();
        tvMoney.setText(bean.getResult().getMoney());
        tvTotal.setText(String.valueOf(bean.getResult().getTotal()));
        tvCash.setText(String.valueOf(bean.getResult().getCash()));
        tvAccount.setText(String.valueOf(bean.getResult().getAccount()));
        tvDayAccount.setText(String.valueOf(bean.getResult().getDay().getAccount()));
        tvDayFans.setText(String.valueOf(bean.getResult().getDay().getFans()));
        tvDayCash.setText(String.valueOf(bean.getResult().getDay().getCash()));
        tvDayNumber.setText(String.valueOf(bean.getResult().getDay().getNumber()));
        tvDayTrueCash.setText(String.valueOf(bean.getResult().getDay().getTrue_cash()));
        tvWeekAccount.setText(String.valueOf(bean.getResult().getWeek().getAccount()));
        tvWeekFans.setText(String.valueOf(bean.getResult().getWeek().getFans()));
        tvWeekCash.setText(String.valueOf(bean.getResult().getWeek().getCash()));
        tvWeekNumber.setText(String.valueOf(bean.getResult().getWeek().getNumber()));
        tvWeekTrueCash.setText(String.valueOf(bean.getResult().getWeek().getTrue_cash()));
        tvMonthAccount.setText(String.valueOf(bean.getResult().getMonth().getAccount()));
        tvMonthFans.setText(String.valueOf(bean.getResult().getMonth().getFans()));
        tvMonthCash.setText(String.valueOf(bean.getResult().getMonth().getCash()));
        tvMonthNumber.setText(String.valueOf(bean.getResult().getMonth().getNumber()));
        tvMonthTrueCash.setText(String.valueOf(bean.getResult().getMonth().getTrue_cash()));
        tvYearAccount.setText(String.valueOf(bean.getResult().getYear().getAccount()));
        tvYearFans.setText(String.valueOf(bean.getResult().getYear().getFans()));
        tvYearCash.setText(String.valueOf(bean.getResult().getYear().getCash()));
        tvYearNumber.setText(String.valueOf(bean.getResult().getYear().getNumber()));
        tvYearTrueCash.setText(String.valueOf(bean.getResult().getYear().getTrue_cash()));
    }


    @OnClick({R.id.ll_btn_left, R.id.tv_btn_tx})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_btn_left:
                finish();
                break;
            case R.id.tv_btn_tx:
                $startActivity(IMoneyTiXianActivity.class);
                break;
        }
    }
}
